/**
 * Created by Administrator on 2017/3/13 0013.
 */




Page9=function() {
        var whole = new PIXI.DisplayObjectContainer();
        var delayTime1=3;
        var delayTime2=7;


        var white=new PIXI.Graphics();
        white.beginFill(0xffffff,1);
        white.drawRect(0,0,1136,740);
        whole.addChild(white);

        var pic1=new PIXI.Sprite(resource["assets/images/p9_1.png"].texture);
        var pic2=new PIXI.Sprite(resource["assets/images/p9_2.png"].texture);
        var pic3=new PIXI.Sprite(resource["assets/images/p9_3.png"].texture);
        var pic4=new PIXI.Sprite(resource["assets/images/p9_4.png"].texture);
        var pic5=new PIXI.Sprite(resource["assets/images/p9_5.png"].texture);

        var pic6=new PIXI.Sprite(resource["assets/images/p9_6.png"].texture);
        var pic7=new PIXI.Sprite(resource["assets/images/p9_7.png"].texture);
        var pic8=new PIXI.Sprite(resource["assets/images/p9_8.png"].texture);
        var pic9=new PIXI.Sprite(resource["assets/images/p9_9.png"].texture);
        var pic10=new PIXI.Sprite(resource["assets/images/p9_10.png"].texture);

        var pic11=new PIXI.Sprite(resource["assets/images/p9_11.png"].texture);

        whole.addChild(pic1);
        whole.addChild(pic2);
        whole.addChild(pic3);
        whole.addChild(pic4);
        whole.addChild(pic5);
        whole.addChild(pic6);
        whole.addChild(pic7);
        whole.addChild(pic8);
        whole.addChild(pic9);
        whole.addChild(pic10);
        whole.addChild(pic11);


        pic1.alpha=0;
        pic2.alpha=0;
        pic3.alpha=0;
        pic4.alpha=0;
        pic5.alpha=0;
        pic6.alpha=0;
        pic7.alpha=0;
        pic8.alpha=0;
        pic9.alpha=0;
        pic10.alpha=0;
        pic11.alpha=0;




        pic1.x=423;pic1.y=81;
        pic2.x=579;pic2.y=81;
        pic3.x=140;pic3.y=350;
        pic4.x=456;pic4.y=347;
        pic5.x=788;pic5.y=349;
        pic6.x=450;pic6.y=194;
        pic7.x=450;pic7.y=194;
        pic8.x=450;pic8.y=194;
        pic9.x=450;pic9.y=194;
        pic10.x=610;pic10.y=355;

        pic11.anchor.set(0.5);
        pic11.x=567.5;pic11.y=271;





        var bala=document.getElementById("bala");
        // bala.style.left=window.innerWidth/2-bala.width/2+"px";
        // bala.style.top=window.innerHeight/2-bala.height/2+"px";
       document.addEventListener("mousedown",function(e){
               console.log(e.target.id);

       })
        document.addEventListener("touchstart",function(e){
                if(e.target.id=="bala"&&bala.style.opacity==1) {
                        bala.className = "qrcode";
                }
        })
        document.addEventListener("touchend",function(e){
                        bala.className = "";
        })

        // bala.className="qrcode";
        var arr=[];
        function balaLeef(){
                for(var z=0;z<81;z++) {
                        for(var y=0;y<11;y++) {
                                var texture = resource["assets/images/p9_11.png"].texture.clone();

                                var square = new PIXI.Rectangle(z*10, y*10, 10, 10);
                                texture.frame = square;
                                var piece = new PIXI.Sprite(texture);
                                piece.x = 161 + z*10;
                                piece.y = 215 + y*10;
                                whole.addChild(piece);
                                piece.alpha=0;
                                arr.push(piece);
                        }
                }
        }
        balaLeef();
        function splitLeef(){
                for(var z=0;z<arr.length;z++){
                        var xx=arr[z].x-Math.random()*400+200;
                        var yy=arr[z].y-Math.random()*400+200;
                        // var xx=470+Math.floor(z/29)*195/29;
                        // var yy=172+(z%29)*195/29;
                        // var yy=172+Math.floor(z%29)*195/29;
                        console.log(xx,yy)
                        TweenMax.to(arr[z],0.7+Math.random()*1,{delay:0,alpha:0,x:xx,y:yy,ease:Cubic.easeInOut});
                }
        }
        var t;
        whole.In=function(){
                pic1.x=423-100;pic2.x=579+100;
                TweenMax.to(pic1,0.8,{delay:0.3,alpha:1,x:423,ease:Cubic.easeOut});
                TweenMax.to(pic2,0.8,{delay:0.3,alpha:1,x:579,ease:Cubic.easeOut});

                pic3.y=350+50;pic4.y=347+50;pic5.y=349+50;
                TweenMax.to(pic3,0.8,{delay:0.8,alpha:1,y:350,ease:Back.easeOut});
                TweenMax.to(pic4,0.8,{delay:1.05,alpha:1,y:347,ease:Back.easeOut});
                TweenMax.to(pic5,0.8,{delay:1.3,alpha:1,y:349,ease:Back.easeOut});


                TweenMax.to(pic3,0.8,{delay:delayTime1+0.5,alpha:0,y:350+50,ease:Back.easeIn});
                TweenMax.to(pic4,0.8,{delay:delayTime1+0.25,alpha:0,y:347+50,ease:Back.easeIn});
                TweenMax.to(pic5,0.8,{delay:delayTime1+0.0,alpha:0,y:349+50,ease:Back.easeIn});

                TweenMax.to(pic1,0.8,{delay:delayTime1+0.7,alpha:0,x:423-100,ease:Back.easeIn});
                TweenMax.to(pic2,0.8,{delay:delayTime1+0.7,alpha:0,x:579+100,ease:Back.easeIn});


                TweenMax.to(pic6,0.7,{delay:delayTime1+1.5,alpha:1,x:253,ease:Cubic.easeOut});
                TweenMax.to(pic7,0.7,{delay:delayTime1+1.4,alpha:1,x:410,ease:Cubic.easeOut});
                TweenMax.to(pic8,0.7,{delay:delayTime1+1.4,alpha:1,x:538,ease:Cubic.easeOut});
                TweenMax.to(pic9,0.7,{delay:delayTime1+1.5,alpha:1,x:710,ease:Cubic.easeOut});

                pic10.y=355+40;
                TweenMax.to(pic10,0.7,{delay:delayTime1+1.8,alpha:1,y:355,ease:Cubic.easeOut});


                TweenMax.to(pic6,0.7,{delay:delayTime2,alpha:0,ease:Cubic.easeOut});
                TweenMax.to(pic7,0.7,{delay:delayTime2,alpha:0,ease:Cubic.easeOut});
                TweenMax.to(pic8,0.7,{delay:delayTime2,alpha:0,ease:Cubic.easeOut});
                TweenMax.to(pic9,0.7,{delay:delayTime2,alpha:0,ease:Cubic.easeOut});
                TweenMax.to(pic10,0.7,{delay:delayTime2,alpha:0,ease:Cubic.easeOut});


                pic11.scale.set(10);
                TweenMax.to(pic11.scale,1,{delay:delayTime2,x:1,y:1,ease:Cubic.easeOut});
                TweenMax.to(pic11,1,{delay:delayTime2,alpha:1,ease:Cubic.easeOut});
                TweenMax.to(pic11,0.01,{delay:delayTime2+1.5,alpha:0,ease:Cubic.easeOut});

                t=setTimeout(function(){
                        for(var z=0;z<arr.length;z++){
                                arr[z].alpha=1;
                        }
                        // pic11.alpha=0;
                        splitLeef();
                        bala.style.zIndex=100;
                // },1)
                },delayTime2*1000+1500);

                bala.style.opacity=0;
                TweenMax.to(bala.style,1,{delay:delayTime2+1.8,opacity:1});

        }
        whole.Out=function(){
                clearTimeout(t);
                bala.style.opacity=0;

                TweenMax.killTweensOf(pic1);
                TweenMax.killTweensOf(pic2);
                TweenMax.killTweensOf(pic3);
                TweenMax.killTweensOf(pic4);
                TweenMax.killTweensOf(pic5);
                TweenMax.killTweensOf(pic6);
                TweenMax.killTweensOf(pic7);
                TweenMax.killTweensOf(pic8);
                TweenMax.killTweensOf(pic9);
                TweenMax.killTweensOf(pic10);
                TweenMax.killTweensOf(pic11);

                setTimeout(function () {
                     pic1.x=423-100;pic2.x=579+100;
                     pic3.y=350+50;pic4.y=347+50;pic5.y=349+50;
                     pic10.y=355+40;
                     pic11.scale.set(10);bala.style.opacity=0;
                        pic1.alpha=0;
                        pic2.alpha=0;
                        pic3.alpha=0;
                        pic4.alpha=0;
                        pic5.alpha=0;
                        pic6.alpha=0;
                        pic7.alpha=0;
                        pic8.alpha=0;
                        pic9.alpha=0;
                        pic10.alpha=0;
                        pic11.alpha=0;
                },200)
        }


        return whole;
    }


